package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.vo.ZsyyParkTicketRefundVo;
import com.ruoyi.system.bo.ZsyyParkTicketRefundQueryBo;
import com.ruoyi.system.bo.ZsyyParkTicketRefundAddBo;
import com.ruoyi.system.bo.ZsyyParkTicketRefundEditBo;
import com.ruoyi.system.service.IZsyyParkTicketRefundService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 取消月票记录Controller
 *
 * @author wangghua
 * @date 2021-07-14
 */
@ApiIgnore
@Api(value = "取消月票记录控制器", tags = {"取消月票记录管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/parkTicketRefund")
public class ZsyyParkTicketRefundController extends BaseController {

    private final IZsyyParkTicketRefundService iZsyyParkTicketRefundService;

    /**
     * 查询取消月票记录列表
     */
    @ApiOperation("查询取消月票记录列表")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRefund:list')")
    @GetMapping("/list")
    public TableDataInfo<ZsyyParkTicketRefundVo> list(@Validated ZsyyParkTicketRefundQueryBo bo) {
        return iZsyyParkTicketRefundService.queryPageList(bo);
    }

    /**
     * 导出取消月票记录列表
     */
    @ApiOperation("导出取消月票记录列表")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRefund:export')")
    @Log(title = "取消月票记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ZsyyParkTicketRefundVo> export(@Validated ZsyyParkTicketRefundQueryBo bo) {
        List<ZsyyParkTicketRefundVo> list = iZsyyParkTicketRefundService.queryList(bo);
        ExcelUtil<ZsyyParkTicketRefundVo> util = new ExcelUtil<ZsyyParkTicketRefundVo>(ZsyyParkTicketRefundVo.class);
        return util.exportExcel(list, "取消月票记录");
    }

    /**
     * 获取取消月票记录详细信息
     */
    @ApiOperation("获取取消月票记录详细信息")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRefund:query')")
    @GetMapping("/{id}")
    public AjaxResult<ZsyyParkTicketRefundVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iZsyyParkTicketRefundService.queryById(id));
    }

    /**
     * 新增取消月票记录
     */
    @ApiOperation("新增取消月票记录")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRefund:add')")
    @Log(title = "取消月票记录", businessType = BusinessType.INSERT)
    @RepeatSubmit
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody ZsyyParkTicketRefundAddBo bo) {
        return toAjax(iZsyyParkTicketRefundService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改取消月票记录
     */
    @ApiOperation("修改取消月票记录")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRefund:edit')")
    @Log(title = "取消月票记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody ZsyyParkTicketRefundEditBo bo) {
        return toAjax(iZsyyParkTicketRefundService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除取消月票记录
     */
    @ApiOperation("删除取消月票记录")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRefund:remove')")
    @Log(title = "取消月票记录" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] ids) {
        return toAjax(iZsyyParkTicketRefundService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
